<template>
  <el-cascader v-model="bindValue" :options="sceneOps" />
</template>

<script>
  import { getSceneList } from '@/api/system/messageTemplate.js';

  /** 业务组件-关联事件下拉选择器 */
  export default {
    name: 'SceneSelector',
    components: {},
    props: {
      modelValue: {
        type: [String, Number, Array],
        default() {
          return '';
        },
      },
    },
    // inheritAttrs: false,
    emits: ['update:modelValue'],
    data() {
      return {
        sceneOps: [],
      };
    },
    computed: {
      bindValue: {
        get() {
          return this.modelValue;
        },
        set(val) {
          this.$emit('update:modelValue', val);
        },
      },
    },
    created() {
      this.getScene();
    },
    methods: {
      getScene() {
        getSceneList().then((res) => {
          this.sceneOps = (res.data || []).map((i) => ({
            value: i.module,
            label: i.moduleName,
            children: i.items.map((j) => ({
              value: j.code,
              label: j.name,
            })),
          }));
        });
      },
    },
  };
</script>

<style lang="scss">
  .ward-select.el-cascader {
    margin-bottom: 8px;
    height: 32px;
    .el-input {
      height: 32px;
    }
    .el-cascader__tags {
      height: 32px;
      display: flex;
      flex-direction: column;
      overflow: auto;
    }
  }
</style>
